import os, sys
sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..')))
from lqueue import LinkQueue

#还是队列求解约瑟夫问题比较简单
def solve_josepy(n, m):
    lq = LinkQueue()
    for i in range(1,n+1):
        lq.push(i)
    while not lq.empty():
        for i in range(m-1):
            x = lq.pop()
            lq.push(x)
        print(lq.pop(), end=' ')
    print()

if __name__ == "__main__":
    solve_josepy(n=6, m=5)
                